<!-- Begin Comments -->
<div>
   <?php /* Run some checks for bots and password protected posts */ ?>
   <?php
      $req = get_option('require_name_email'); // Checks if fields are required.
      if ( 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']) )
          die ( 'Please do not load this page directly. Thanks!' );
      if ( ! empty($post->post_password) ) :
          if ( $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password ) :
      ?>
   <div class="alert-box warning nopassword"><?php _e('This post is password protected. Enter the password to view any comments.', 'Foundation') ?></div>
</div>
<?php
   return;
   endif;
   endif;
   ?>
<!-- End Comments -->
<?php if ( have_comments() ) : ?>
<?php
   $ping_count = $comment_count = 0;
   foreach ( $comments as $comment )
      get_comment_type() == "comment" ? ++$comment_count : ++$ping_count;
   ?>
<?php if ( ! empty($comments_by_type['comment']) ) : ?>
<!-- Begin Comments List -->
<div id="comments-list" class="comments">
   <h4 class="subheader"><?php printf($comment_count > 1 ? __('<span>%d</span> Comments', 'Foundation') : __('<span>One</span> Comment', 'Foundation'), $comment_count) ?></h4>
   <!-- Begin Navigation (Above) -->
   <?php $total_pages = get_comment_pages_count(); if ( $total_pages > 1 ) : ?>
   <div id="comments-nav-above" class="comments-navigation">
      <div class="paginated-comments-links"><?php paginate_comments_links(); ?></div>
   </div>
   <?php endif; ?>       
   <!-- End Navigation -->            
   <ol>
      <?php wp_list_comments('type=comment&callback=custom_comments'); ?>
   </ol>
   <!-- Begin Navigation (Below) -->
   <?php $total_pages = get_comment_pages_count(); if ( $total_pages > 1 ) : ?>
   <div id="comments-nav-below" class="comments-navigation">
      <div class="paginated-comments-links"><?php paginate_comments_links(); ?></div>
   </div>
   <?php endif; ?>
   <!-- End Navigation (Below) -->
</div>
<!-- End Comments List -->
<?php endif; /* if ( $comment_count ) */ ?>
<?php /* If there are trackbacks(pings), show the trackbacks  */ ?>
<?php if ( ! empty($comments_by_type['pings']) ) : ?>
<div id="trackbacks-list" class="comments">
   <h3><?php printf($ping_count > 1 ? __('<span>%d</span> Trackbacks', 'Foundation') : __('<span>One</span> Trackback', 'Foundation'), $ping_count) ?></h3>
   <?php /* An ordered list of our custom trackbacks callback, custom_pings(), in functions.php   */ ?>
   <ol>
      <?php wp_list_comments('type=pings&callback=custom_pings'); ?>
   </ol>
</div>
<!-- #trackbacks-list .comments -->           
<?php endif /* if ( $ping_count ) */ ?>
<?php endif /* if ( $comments ) */ ?>
<?php /* If comments are open, build the respond form */ ?>
<?php if ( 'open' == $post->comment_status ) : ?>
<div>
   <fieldset>
      <legend>
         <h4 class="subheader">
            <?php comment_form_title( __('Post a Comment', 'Foundation'), __('Post a Reply to %s', 'Foundation') ); ?>
         </h4>
      </legend>
      <div id="cancel-comment-reply"><?php cancel_comment_reply_link() ?></div>
      <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
      <p id="login-req"><?php printf(__('You must be <a href="%s" title="Log in">logged in</a> to post a comment.', 'Foundation'),
         get_option('siteurl') . '/wp-login.php?redirect_to=' . get_permalink() ) ?></p>
      <?php else : ?>
      <?php comment_form(); ?>
      <!-- .formcontainer -->
      <?php endif /* if ( get_option('comment_registration') && !$user_ID ) */ ?>
</div>
<!-- #respond -->
</fieldset>
<?php endif /* if ( 'open' == $post->comment_status ) */ ?>
</div><!-- #comments -->
